<template>
  <div>
    <ul>
      <li v-for="item in arr" :key="item._id">
        {{item.name}}
        {{item._id}}
        <button @click="del(item._id)">删除</button>
        <hr>
      </li>
    </ul>
  </div>
</template>
<script>
import { test, getData, addmember,removeMember } from "../api/index";
export default {
  data() {
    return {
      name: "言和",
      arr: []
    };
  },
  mounted() {
    const _this = this;
    _this.getlist();
    _this.bus.$on("send", function(inp) {
      //console.log(112222,inp)
      addmember(inp).then(function() {
        _this.getlist();
      });
    });
  },
  methods: {
    getlist() {
      getData().then(res => {
        //console.log(res.data.data);
        this.arr = res.data.data;
      });
    },
    del(ipt){
        
        const _this =this;
        removeMember(ipt).then(function(){
            _this.getlist()
            //console.log(ipt)
        })
    }
  }
};
</script>
<style scoped>
</style>